#ifndef __DRECODEC_HH__
#define __DRECODEC_HH__

#define MAX_CHUNK_SIZE 1500

typedef enum {ReOutbound=-1, ReInbound = 1} ReDirection;

typedef enum {
    ReEGeneralFailure = -2,
    ReEInsufficientBuffer = -1,
    ReECompressedStored = 1, 
    ReECompressedNotStored = 2,
    ReENotCompressedStored=3
}  __attribute__((__packed__)) ReEncodingStatus;

typedef enum {
    ReDGeneralFailure = -2,
    ReDInsufficientBuffer = -1,
    ReDPacketStored = 1,
    ReDPacketDecoded = 2,
    ReDPacketDecodedStored = 3
}  __attribute__((__packed__)) ReDecodingStatus;

typedef union {
    ReEncodingStatus encoding;
    ReDecodingStatus decoding;
} ReStatus;

   /* initialization function */
   /* returns pointer to object */
   /* context - 0 for now */
   /* might need multiple contexts */

#ifdef __cplusplus
extern "C" {
#endif

void * InitReEngine(int context, const char *db_name);

void ShutdownReEngine(void * engine);

int ReEncode(void *engine, unsigned char *inbuffer, int insize,
                       unsigned char *outbuffer, int out_length, ReStatus *vp,
                       unsigned short *lengths, int pair_count);

int ReDecode(void *engine, unsigned char *inbuffer, int insize, 
	     unsigned char *outbuffer, int outsize, ReStatus *vp,
             unsigned short *lengths, int pair_count);

struct ReEngineStats {
  unsigned long index_puts;
  unsigned long index_deletes;
  unsigned long index_found;
  unsigned long index_notfound;
  unsigned long disk_cache_purges;
  unsigned long disk_cache_gets;
  unsigned long disk_cache_saves;
};

#ifndef __cplusplus
typedef int bool;
#endif

bool ReGetStats(void *engine, struct ReEngineStats *pstats);

#ifdef __cplusplus
}
#endif

#endif
